package com.prestamomo.vil.ppa.pmvilnet.pmvilutils;

import org.json.JSONObject;

import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class PmvilHttpBodyOrStr {

    /**
     * @param pmvilPams
     * @return
     */
    public static RequestBody getPmvilRequestBy(Map<String, Object> pmvilPams) {
        JSONObject jsonPmvilObj = new JSONObject(pmvilPams);
        return RequestBody.create(MediaType.parse("text/plain;charset=utf-8"), PmvilAnalyze.analyzePmvilCopy(jsonPmvilObj.toString(), false));
    }

    /**
     * @param pmvilStr
     * @return
     */
    public static RequestBody getPmvilRequestBy(String pmvilStr) {
        return RequestBody.create(MediaType.parse("text/plain;charset=utf-8"), PmvilAnalyze.analyzePmvilCopy(pmvilStr, false));
    }

    public static String getPmvilMethStr(Map<String, Object> pmvilMap) {
        JSONObject pmvilJsonMap = new JSONObject(pmvilMap);
        return PmvilAnalyze.analyzePmvilCopy(pmvilJsonMap.toString(), false);
    }

}
